﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _3DLines
{
    class Program
    {
        static char[,,] cube;
        static int maxLength = -1;
        static int linesNumber =0;
        static int width = 0;
        static int height = 0;
        static int depth = 0;
        static Dictionary<string, Direction> Directions = new Dictionary<string, Direction>();
        static Dictionary<string, Direction> reverseDirections = new Dictionary<string, Direction>();
        static Direction currentDirection;

        static void Main(string[] args)
        {
            readInput();
            generateDirections();
            foreach (var item in Directions)
            {
                currentDirection = item.Value;
                for (int w = 0; w < width; w++)
                {
                    for (int h = 0; h < height; h++)
                    {
                        for (int d = 0; d < depth; d++)
                        {
                            checkNeighbours(w, h, d, 0);
                            //counter++;
                            //Console.WriteLine("{0} {1} {2}", w,h,d);
                        }
                    }
                }
            }
            //Console.WriteLine(counter2);
            Console.WriteLine("{0} {1}", maxLength, linesNumber);
        }

        private static void generateDirections()
        {
            for (int w = -1; w < 2; w++)
            {
                for (int h = -1; h < 2; h++)
                {
                    for (int d = -1; d < 2; d++)
                    {
                        //if (w==1 && h==1 && d==1)
                        //{
                        //    Console.WriteLine();
                        //}
                        if (!Directions.ContainsKey(""+w+h+d)
                            && !reverseDirections.ContainsKey("" + w + h + d)
                            && !(w==0 && h==0 && d==0))
                        {
                            Direction direction = new Direction(w, h, d);
                            Directions.Add(direction.Name, direction);
                            Direction reverseDirection = direction.GetOposite();
                            reverseDirections.Add(reverseDirection.Name, reverseDirection);
                        }
                    }
                }
            }
        }

        private static void checkNeighbours(int currentWidth, int currentHeight, int currentDepth, int currentLine)
        {
            currentLine++;
            if (currentLine > maxLength)
            {
                maxLength = currentLine;
                linesNumber = 1;
            }
            else if (currentLine == maxLength)
            {
                linesNumber++;
            }
            if (chekcCube(currentWidth + currentDirection.W, currentHeight + currentDirection.H, currentDepth + currentDirection.D, cube[currentWidth, currentHeight, currentDepth]))
            {
                checkNeighbours(currentWidth + currentDirection.W, currentHeight + currentDirection.H, currentDepth + currentDirection.D, currentLine);
            }

        }

        private static bool chekcCube(int cubeWidth, int cubeHeight, int cubeDepth, char colour)
        {
            if (
                cubeWidth >= 0 &&
                cubeHeight >= 0 &&
                cubeDepth >= 0 &&
                cubeWidth < width &&
                cubeHeight < height &&
                cubeDepth < depth &&
                colour == cube[cubeWidth,cubeHeight, cubeDepth]
                 )
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        private static void readInput()
        {
            int[] dimentions = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(m => int.Parse(m)).ToArray();
            width = dimentions[0];
            height = dimentions[1];
            depth = dimentions[2];
            cube = new char[width, height, depth];
            for (int h = 0; h < height; h++)
            {
                string[] inputLine = Console.ReadLine().Split(new char[] {' '},StringSplitOptions.RemoveEmptyEntries);
                for (int d = 0; d < depth; d++)
                {
                    for (int w = 0; w < width; w++)
                    {
                        cube[w, h, d] = inputLine[d][w];
                    }
                }
            }
        }
        class Direction
        {
            public string Name;
            public int W { get; set; }
            public int H { get; set; }
            public int D { get; set; }

            public Direction(int W, int H, int D)
            {
                this.Name = "" + W + H + D;
                this.W = W;
                this.H = H;
                this.D = D;
            }
            public Direction GetOposite()
            {
                return new Direction(this.W*(-1), this.H*(-1), this.D*(-1));  
            }
        }
        
    }
}
